package com.hippo.core.ui.compose.setting

import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.hippo.core.R
import com.hippo.core.ui.components.CheckText
import com.hippo.core.ui.components.CommonDialog
import com.hippo.core.ui.components.ThemeButton
import com.hippo.core.ui.theme.HippoTheme

@Composable
fun ModeDialog(currentMode:Int,onDismissRequest: () -> Unit,onSave: (Int) -> Unit) {

    var mode by remember { mutableStateOf(currentMode) }

    CommonDialog(
        title = stringResource(R.string.mode_1),
        onDismissRequest = onDismissRequest,
    ) {

        CheckText(stringResource(R.string.mode_2), mode == 1) {
            mode = 1
        }

        CheckText(stringResource(R.string.mode_3), mode == 2) {
            mode = 2
        }


        Spacer(modifier = Modifier.height(26.dp))


        ThemeButton(text = stringResource(R.string.save)) {
            onSave(mode)
            onDismissRequest()
        }

    }
}

@Preview
@Composable
private fun ModeDialogPreview() {
    HippoTheme {
        ModeDialog(
            currentMode = 1,
            onDismissRequest = {},
            onSave = {}
        )
    }
}


